package lib.wzh.com.libcore.cloud.mybatis;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author lib
 * @Date 2021/11/30 16:19
 * @ClassName MyBatisPlusConfiguration
 * @Version v1.0
 */


@Configuration
public class MyBatisPlusConfiguration {

    public MyBatisPlusConfiguration() {
    }

    /** 分页插件
     * @author lib
     * @date 2021/11/30 16:29
     * @since: jdk1.8
     * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusLimitInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }

    /** 乐观锁
     * @author lib
     * @date 2021/11/30 16:29
     * @since: jdk1.8
     * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }

}
